<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <script>
    let age=[]
    let sum=0
    let average

    function panDuan(num,i,sum){
      if(num>0&&num<=100){
        age.push(num)
        sum+=age[i-1]
        average=sum/i
      }else{
        alert('请输入正确的年龄,区间为0~100')
        num=Number(prompt(`第${i}次输入年龄`))
        panDuan(num,i)
      }
    }

    for(let i=1;i<=5;i++){
      let num=Number(prompt(`第${i}次输入年龄`))
      if(num>0&&num<=100){
        age.push(num)
        sum+=age[i-1]
        average=sum/i
      }else{
        alert('请输入正确的年龄,区间为0~100')
        num=Number(prompt(`第${i}次输入年龄`))
        panDuan(num,i,sum)
      }
    }
    let max=age[0]
    let min=age[0]

    for(i=0;i<age.length;i++){
      if(age[0]<age[i]){
        max=age[i]
      } else{
        min=age[i]
      }
    }
    document.write(`<p>${sum}</p>`);
    document.write(`<p>${age}</p>`);
    document.write(`<p>${average}</p>`);
    document.write(`<p>${max}</p>`);
    document.write(`<p>${min}</p>`);
    
  
    
  </script>
</body>
</html>